package com.uvnos4j.matilda.commons.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

/**
 * Id Domain
 * <p>
 * Description:Id Domain。提供基于雪花算法的Id处理。
 * </p>
 *
 * @author Guo.wl
 * @version v1.0.0
 * @see com.uvnos4j.matilda.commons.domain
 * @since 2020-08-31 22:34:15
 */
@Data
public class IdDomain {

    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    // 参数1为终端ID
    // 参数2为数据中心ID
    // 分布式ID的雪花算法及坑: https://www.cnblogs.com/jpfss/p/11507009.html, 影响范围：主键及外键
    // private static Snowflake snowflake = IdUtil.createSnowflake(1, 1);
    //
    // protected String id;
    //
    // public IdDomain() {
    // id = snowflake.nextIdStr();
    // }

}